package com.yupi.usercenter.commons;

import lombok.Data;

import java.io.Serializable;

/**
 * @author 麦翔盛
 * @ClassName: BaseResponse
 * @Package: com.yupi.commons
 * @description: 统一相应类
 * @date 2022/4/13 15:05
 */
@Data
public class BaseResponse<T> implements Serializable {

    /**
     * 响应码
     */
    private Integer code;

    /**
     * 响应信息
     */
    private String message;

    /**
     * 相应数据
     */
    private T data;

    /**
     * 响应具体描述
     */
    private String description;

    public BaseResponse(Integer code, String message, T data,String description) {
        this.code = code;
        this.message = message;
        this.data = data;
        this.description = description;
    }

    public BaseResponse(Integer code,T data,String message) {
        this(code,message,data,"");
    }

    public BaseResponse(Integer code,T data) {
        this(code,"",data,"");
    }

    public BaseResponse(ErrorCode errorCode) {
        this(errorCode.getCode(),errorCode.getMessage(),null,errorCode.getDescription());
    }

    public BaseResponse(ErrorCode errorCode,String description) {
        this(errorCode.getCode(),errorCode.getMessage(),null,description);
    }

    public BaseResponse(ErrorCode errorCode,String message,String description) {
        this(errorCode.getCode(),message,null,description);
    }



}
